class Student {
    private String name;
    private int age;
    // 构造方法
    public Student(int age,String name){
        this.name = name;
        this.age = age;
    }
    // 重写hashCode()
    public int hashCode(){
        return name.hashCode()+age;
    }
    // 重写equals()
    public boolean equals(Object obj){
        if(this==obj){
            return true;  //判断是否为同一个对象，是的话返回true
        }
        if(!(obj instanceof Student)){
            return false;  // 如果对象不是Student返回false
        }
        Student stu = (Student) obj;// 将对象强制转换为Student类型
        //boolean a = this.name.equals(stu.name);
        if(this.name.equals(stu.name)&&this.age==stu.age){
            return true;
        }else{
            return false;
        }
    }
    // 重写toString()

    @Override
    public String toString() {
        return age+":"+name;
    }

    // get,set方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
